/**
 * Copyright 厦门中软海晟信息技术有限公司 版权所有 违者必究 2019
 */
package com.zf.platform.entity;

import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.Basic;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import java.util.Date;
import java.util.UUID;

/**
 * @author : sunzb(sunzb@hsit.com.cn)
 * @date: 2019/1/7
 */
@MappedSuperclass
public class BaseEntity {
    @Id
    private String id;
    private Date createDate;
    private String createBy;
    private Date updateDate;

    @PrePersist
    public void beforeCreate() {
        this.id = StringUtils.replace(UUID.randomUUID().toString(), "-", "");
        this.createDate = new Date();
    }

    public String getCreateBy() {
        return createBy;
    }

    public BaseEntity setCreateBy(String createBy) {
        this.createBy = createBy;
        return this;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public BaseEntity setCreateDate(Date createDate) {
        this.createDate = createDate;
        return this;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public BaseEntity setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
        return this;
    }

    public String getId() {
        return id;
    }

    public BaseEntity setId(String id) {
        this.id = id;
        return this;
    }
}
